<template>
  <div class="rebuild-list">
    <el-card>
      <template #header>
        <div class="card-header">
          <span>备份任务检查列表</span>
          <div>
            <el-button type="primary" @click="goToKilob">数据库备份情况</el-button>
          </div>
        </div>
      </template>
      
      <el-table :data="rebuildTasks" style="width: 100%" v-loading="loading">
        <el-table-column prop="id" label="ID" width="180" />
        <el-table-column prop="type" label="类型" width="180" />
        <el-table-column prop="status" label="状态" width="180">
          <template #default="scope">
            <el-tag :type="scope.row.status === 'success' ? 'success' : 'danger'">
              {{ scope.row.status }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="createdAt" label="创建时间" />
      </el-table>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { getBackupListHandler } from '../../api/check.js'

const router = useRouter()
const loading = ref(false)
const rebuildTasks = ref([])

const goToKilob = () => {
  router.push('/rebuild/kilob')
}

const goToPerformance = () => {
  router.push('/rebuild/performance')
}


onMounted(() => {
  getRebuildList()
})
</script>

<style scoped>
.rebuild-list {
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>